package servlet;

import dao.impl.UserDaoImpl;
import dao.intf.UserDao;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author jiaohongtao
 * @version 1.0
 * @since 2020年09月02日
 */
@WebServlet("/userList")
public class UserServlet extends HttpServlet {

    @Autowired
    UserDao userDao;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // super.doGet(req, resp);

        // req.getSession().setAttribute("userList", userDao.list());
        req.getSession().setAttribute("userList", new UserDaoImpl().list());
        resp.sendRedirect("view/user.jsp");
    }
}
